﻿using System.Collections.Generic;
using System.Web.Mvc;
using System.Web.Routing;
using Orchard.Mvc.Routes;

namespace Amba.KeyValueStorage
{
    public class Routes : IRouteProvider
    {
        public void GetRoutes(ICollection<RouteDescriptor> routes)
        {
            foreach (var routeDescriptor in GetRoutes())
            {
                routes.Add(routeDescriptor);
            }
        }

        public IEnumerable<RouteDescriptor> GetRoutes()
        {
            var routes = new List<RouteDescriptor>();


            routes.Add(new RouteDescriptor
                {
                    Priority = 1,
                    Route = new Route(
                           "amba.kvs/get",
                           new RouteValueDictionary
                               {
                                   {"area", "Amba.KeyValueStorage"},
                                   {"controller", "KeyValue"},
                                   {"action", "Get"}
                               },
                           new RouteValueDictionary(),
                           new RouteValueDictionary { { "area", "Amba.KeyValueStorage" } },
                           new MvcRouteHandler())
                });
            routes.Add(new RouteDescriptor
            {
                Priority = 1,
                Route = new Route(
                       "amba.kvs/set",
                       new RouteValueDictionary
                               {
                                   {"area", "Amba.KeyValueStorage"},
                                   {"controller", "KeyValue"},
                                   {"action", "Set"}
                               },
                       new RouteValueDictionary(),
                       new RouteValueDictionary { { "area", "Amba.KeyValueStorage" } },
                       new MvcRouteHandler())
            });
            routes.Add(new RouteDescriptor
            {
                Priority = 1,
                Route = new Route(
                       "amba.kvs/token",
                       new RouteValueDictionary
                               {
                                   {"area", "Amba.KeyValueStorage"},
                                   {"controller", "KeyValue"},
                                   {"action", "AntiValidationToken"}
                               },
                       new RouteValueDictionary(),
                       new RouteValueDictionary { { "area", "Amba.KeyValueStorage" } },
                       new MvcRouteHandler())
            });
            return routes;
        }
    }
}